'use strict';
module.exports = {
	/**
	 * 查询邀请列表
	 * @url client/user/kh/getInviteList 前端调用的url参数地址
	 * data 请求参数 说明
	 * @param {String} client  客户端 
	 * @param {Number} page  页码
	 * @param {Number} pageSize  每页条数 
	 */
	main: async (event) => {
		let { data = {}, userInfo, util, filterResponse, originalParam } = event;
		let { customUtil, uniID, config, pubFun, vk, db, _ } = util;
		let { uid } = data;
		let res = { code: 0, msg: "" };
		// 业务逻辑开始-----------------------------------------------------------
		let { client, page, pageSize } = data;

		let whereJson = {
			client: client,
			partner_grade: userInfo.partner_grade + 1,
			superior_code: userInfo.my_invite_code
		};
		
		let dbName = "uni-id-users";
		
		res["data"] = await vk.baseDao.selects({
			dbName,
			getMain: true,
			whereJson,
			pageIndex: page || 1,
			pageSize: pageSize || 10,
			sort: [{name: '_add_time', type: "desc"}]
		})

		// 业务逻辑结束-----------------------------------------------------------
		return res;
	}
}
